//-----------------------------------------------------------------------
// <copyright file="CountryService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class CountryService
    {
        #region Country

        public static void CreateCountry(Country country)
        {            
            try
            {
                CountryDAO countryDAO = new CountryDAO();
                countryDAO.CreateCountry(country);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateCountryException, ex);
            }
        }        

        public static void UpdateCountry(Country country)
        {            
            try
            {
                CountryDAO countryDAO = new CountryDAO();
                countryDAO.UpdateCountry(country);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateCountryException, ex);
            }
        }        

        public static void DeleteCountry(long countryId)
        {            
            try
            {
                CountryDAO countryDAO = new CountryDAO();
                countryDAO.DeleteCountry(countryId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteCountryException, ex);
            }
        }
        
        public static Country GetCountry(long countryId)
        {            
            try
            {
                CountryDAO countryDAO = new CountryDAO();
                return countryDAO.GetCountry(countryId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCountryException, ex);
            }
        }                

        public static CountryCollection GetCountryList(CountryColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                CountryDAO countryDAO = new CountryDAO();
                return countryDAO.GetCountryList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCountryListException, ex);
            }
        }        

        public static CountryCollection GetCountryList(CountryColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                CountryDAO countryDAO = new CountryDAO();
                return countryDAO.GetCountryList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCountryListException, ex);
            }
        }        

	    public static CountryCollection GetCountryListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                CountryDAO countryDAO = new CountryDAO();
                return countryDAO.GetCountryListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCountryListException, ex);
            }
        }        

        public static CountryCollection GetCountryListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                CountryDAO countryDAO = new CountryDAO();
                return countryDAO.GetCountryListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCountryListException, ex);
            }
        }        

        #endregion
    }
}